from Base import message, intersect, SS_VALID
from ADRG import AA1,AA2,AB1,AC1,AD1,AE1,AF1,AG1,AG2,AG3,AH1,AH2

def group(record):
  mdc_zd = []
  adrg_zd1 = ["Z93.000"]
  adrg_ss = ["33.6x00","37.5100","37.5100x001","50.5902","50.5100","50.5100x001","50.5100x002","50.5900x001","50.5900x004","50.5900x005","50.5901","52.8000","52.8200","52.8300","55.6100","55.6901","33.5000","33.5000x001","33.5100","33.5200","41.0200","41.0800x001","41.0300","41.0500","41.0600","41.0000","41.0100","41.0401","41.0701","41.0900","37.5200x001","39.6500","31.1x00x005","31.2100x001","31.2900x001","31.7400","31.7400x001","96.0400","96.5500","96.7201"]
  adrg_ss1 = ["96.7201"]
  dept_list=[]

  if not (True and record.ssList and intersect(record.ssList, adrg_ss)):
      return ''
    
  message('符合MDCA入组条件，匹配规则：存在手术')
    
  result=AA1.group(record)
  if result:
    return result
  result=AA2.group(record)
  if result:
    return result
  result=AB1.group(record)
  if result:
    return result
  result=AC1.group(record)
  if result:
    return result
  result=AD1.group(record)
  if result:
    return result
  result=AE1.group(record)
  if result:
    return result
  result=AF1.group(record)
  if result:
    return result
  result=AG1.group(record)
  if result:
    return result
  result=AG2.group(record)
  if result:
    return result
  result=AG3.group(record)
  if result:
    return result
  result=AH1.group(record)
  if result:
    return result
  result=AH2.group(record)
  if result:
    return result
  elif intersect(record.ssList, adrg_ss1):
    return 'AQY'


  message('不符合MDCA的ADRG入组条件')
